package com.mew.lobby.handler.user;


import com.mew.common.exception.ResponseCode;
import com.mew.common.rest.StringMessage;
import com.mew.common.rest.bo.MewSession;
import com.mew.common.rest.user.UserDetailedInfoResponseMessage;
import com.mew.lobby.annotation.LobbyHandler;
import com.mew.lobby.net.LobbyHandlerMapCmdType;
import com.mew.lobby.net.MewHandler;
import com.mew.lobby.provide.UserFeignService;
import com.zebra.remoting.protocol.ZebraCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author dylin
 * @create 2021/5/11
 */
@Service
@Slf4j
@LobbyHandler(LobbyHandlerMapCmdType.UserDetailedInfoByGid)
public class DetailedInfoByGidHandler implements MewHandler<StringMessage> {
    @Autowired
    private UserFeignService userFeignService;


    @Override
    public void handle(ZebraCommand<StringMessage> zebraCommand, MewSession session) {
        String gid=zebraCommand.getRequest().getS();
        UserDetailedInfoResponseMessage du=userFeignService.getDetailedInfoByGid(session.uid,gid);
        if(null==du){
            zebraCommand.sendFailureCode(ResponseCode.UserNotExist.code());
        }else {
            zebraCommand.sendMessage(du);
        }
    }
}
